#ifndef _LZ77_H_
#define _LZ77_H_

#include "CommonHead.h"
#include "HashTable.h"

class LZ77{
public:
	LZ77();
	~LZ77();
	void Compress(const string& filename);
	void DeCompress(const string& filename);
	void BitFlagInfo(FILE* bit_flag, u_sh match_dist, u_ch& bit_info, u_ch& bit_cnt);
private:
	u_sh LongestMatch(u_sh matchHead, u_sh& matchDist, u_sh start);
	void FillWindow(FILE* file_in, u_ll& read_size, u_sh& start);
	string GetFileName(const string& filename);
	string GetFilePostfix(const string& filename);
	void GetLine(FILE* in, string& str);
private:
	u_ch* _pwin;
	HashTable hash;

	const u_sh  MIN_READ_SIZE = MIN_MATCH + MAX_MATCH + 1;
	const u_sh  MAX_DIST = WSIZE - MIN_READ_SIZE;   // 最远查找距离
};

#endif